#ifndef CHESSMAN_H
#define CHESSMAN_H

#include "Point.h"
#include "graph.h"
#include "Touch_window.h"

using namespace Graph_lib;

class Chessman {
	friend class Gameboard;
public:
	void change_icon(const string& image_name);	//choose or unchoose one chessman then change icon
	virtual bool move_valid(int i, int j, Gameboard& g) = 0; //check if the move target is valid
	virtual bool eat_valid(int i, int j, Gameboard& g) = 0;	//check if the eat behavior is valid
protected:
	Chessman() { };
	int init_i;	//initial position
	int init_j;	//initial position
	int cur_i;	//current position
	int cur_j;	//current position
	int last_i; //last position
	int last_j;	//last position
	Image* icon;	//icon
	bool turn;	//mark the turn of the play
	bool choosed;	//mark if the chessman has been choosed
	bool color;	//1 for red,0 for black
	vector< vector<string> > image_name;	//store the names of four images:black&&unchoosed,black&&choosed,red&&unchoosed,red&&choosed
};

class King : public Chessman {
public:
	King(int i, int j, bool col);
protected:
	bool move_valid(int i, int j, Gameboard& g);
	bool eat_valid(int i, int j, Gameboard& g);
};

class Advisor : public Chessman {
public:
	Advisor(int i, int j, bool col);
protected:
	bool move_valid(int i, int j, Gameboard& g);
	bool eat_valid(int i, int j, Gameboard& g);
};

class Elephant : public Chessman {
public:
	Elephant(int i, int j, bool col);
protected:
	bool move_valid(int i, int j, Gameboard& g);
	bool eat_valid(int i, int j, Gameboard& g);
};

class Horse : public Chessman {
public:
	Horse(int i, int j, bool col);
protected:
	bool move_valid(int i, int j, Gameboard& g);
	bool eat_valid(int i, int j, Gameboard& g);
};

class Chariot : public Chessman {
public:
	Chariot(int i, int j, bool col);
protected:
	bool move_valid(int i, int j, Gameboard& g);
	bool eat_valid(int i, int j, Gameboard& g);
};

class Cannon : public Chessman {
public:
	Cannon(int i, int j, bool col);
protected:
	bool move_valid(int i, int j, Gameboard& g);
	bool eat_valid(int i, int j, Gameboard& g);
};

class Pawn : public Chessman {
public:
	Pawn(int i, int j, bool col);
protected:
	bool move_valid(int i, int j, Gameboard& g);
	bool eat_valid(int i, int j, Gameboard& g);
};

#endif

